package com.bwie.controller;

import com.bwie.common.domain.Card;
import com.bwie.common.domain.request.BorrowRequest;
import com.bwie.common.result.Result;
import com.bwie.service.BorrowService;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/borrow")
@CrossOrigin
public class BorrowController {

    @Autowired
    private BorrowService borrowService;

    @PostMapping("/list")
    public Result<PageInfo<BorrowRequest>> list(@RequestBody BorrowRequest borrow){
        PageInfo<BorrowRequest> list = borrowService.list(borrow);
        return Result.success(list);
    }

    @PostMapping("/upd")
    public Result<BorrowRequest> upd(@RequestBody BorrowRequest borrow){
        borrowService.upd(borrow);
        return Result.success();
    }

    @PostMapping("/cardList")
    public Result<PageInfo<Card>> cardList(@RequestBody Card card){
        PageInfo<Card> list = borrowService.cardList(card);
        return Result.success(list);
    }

}
